#include "htil.hpp"


class Index
{
private:
    std::vector<docInfo> forward_index_;
    std::unordered_map<std::string, docInfo> inverted_index_;
public:
    // 构建正排
    bool BuildForwardIndex(const std::string out_path)
    {
        std::ifstream in(out_path.c_str());
        if(!in.is_open())
        {
            std::cerr << "文件打开失败, 请检查路径" << std::endl;
            return false;
        }
        std::string line;
        while(std::getline(in, line))
        {
            docInfo doc;
            common::SplitLineToDoc(&doc, line, "\3");
            forward_index_.push_back(doc);
        }
        std::cout << forward_index_.size() << std::endl;
        return true;
    }
    // 构建倒排
    bool BuildInvertedIndex()
    {

    }
};


class Search
{
private:
    Index index_;
public:
    bool init(const std::string out_path)
    {
        if(!index_.BuildForwardIndex(out_path))
        {
            std::cerr << "正排构建失败" << std::endl;
            return false;
        }
        return true;
    }

};